﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace Obra.Test
{
    [TestFixture]
    public class HttpServerQueuedContentTester
    {
        private Uri uri = new Uri(Messages.TestUrl);

        [Test]
        public void HttpServerTest()
        {
            using (HttpServerQueuedContent httpServer = new HttpServerQueuedContent(this.uri))
            {
                string content = "<html></html>";
                httpServer.ContentQueue.Enqueue(content);
                httpServer.Start();

                string data = TestHelper.Fetch(new Uri(Messages.TestUrl));
                Assert.AreEqual(content, data);
            }
        }

        [Test]
        public void HttpServerTestMultipleRequests()
        {
            using (HttpServerQueuedContent httpServer = new HttpServerQueuedContent(this.uri))
            {
                string content = "<html></html>";
                httpServer.ContentQueue.Enqueue(content);
                httpServer.ContentQueue.Enqueue(content);
                httpServer.Start();

                Func<string> fetch = () => TestHelper.Fetch(new Uri(Messages.TestUrl));

                Assert.AreEqual(content, fetch.Invoke());
                Assert.AreEqual(content, fetch.Invoke());
            }
        }
    }
}
